package com.tjec.project.mdmSynchronous.dao.impl;


import com.tjec.common.utils.StringUtils;
import com.tjec.project.mdmSynchronous.dao.ProjectContractDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @wjq
 * @date2019/8/29
 */
@Service
public class ProjectContractImpl implements ProjectContractDao {

    @Autowired
    private JdbcTemplate primaryJdbcTemplate;

    @Override
    public List<Map<String, Object>> getProjectContractList(String code,long time) {
        String sql="SELECT b.[项目合同全局ID] as globalId,b.项目代码 as code,\n" +
                "b.合同编号 as coprojectId,b.合同名称 as name,b.签约日期 as signDate,\n" +
                "b.合同性质 as nature, b.合同取费方法条款 as feeCollectionTerms,\n" +
                "b.[合同服务期条款] as serverTerms,b.[合同服务内容备注] as serviceContentRemark,\n" +
                "b.[合同签约单位备注] as signingUnitRemark,b.[合同项目概况备注] projectOverviewRemark,\n" +
                "b.[合同其它备注] as otherRemark ,CONVERT(BIGINT,b.项目合同时间戳) as timestamp\n" +
                ",b.[合同统计范围] as scopeOf   FROM [TO_EC_实施台帐_项目实施] as a " +
                "left join [TO_EC_实施台帐_项目合同] as b on a.[项目代码]=b.[项目代码]" +
                "where 1=1 and b.[合同统计范围] like '%外部统计%' ";
              if(StringUtils.isNotBlank(code)){
                  sql =sql+" and a.项目代码='"+code+"'";
              }
               if(time>0){
                   sql =sql+" and CONVERT(BIGINT,b.项目合同时间戳)>"+time;
             }

        return  primaryJdbcTemplate.queryForList(sql);
    }

}
